package com.spz.demo.scloud.consumer.openfeign.config;

import com.netflix.ribbon.Ribbon;
import feign.Logger;
import feign.Request;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * OpenFeign 配置
 * @author spzmmd
 * @createTime 2021/04/12
 */
@Configuration
public class OpenFeignConfiguration {

    /**
     * 连接超时
     * 单位: ms
     */
    @Value("${openfeign.connectTimeoutMs}")
    private int connectTimeoutMs;

    /**
     * 读取超时
     * 单位: ms
     */
    @Value("${openfeign.readTimeoutMs}")
    private int readTimeoutMs;

    /**
     * 配置超时
     * @return
     */
    @Bean
    public Request.Options options() {
        return new Request.Options(connectTimeoutMs, readTimeoutMs);
    }

    /**
     * 配置OpenFeign输出什么日志
     * @return
     */
    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }
}
